/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.edu.kamai.xmlparser;

import java.io.FileWriter;
import java.io.IOException;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.output.Format;
import org.jdom.output.XMLOutputter;

/**
 *
 * @author xyzhu
 */
public class answerGeneration {
 
    public void generateXML(){
        
    }
    
    protected Element generateHead(int pid, String uid){
        String sPaperRoleID = Integer.toString(pid);
	Element root = new Element("PaperID").setText(sPaperRoleID);
        root.setAttribute("UserID", uid);
        return root;
    }
    
    public void writeToDisk(String fileName){
        try {
            FileWriter writer = new FileWriter(fileName + ".xml");   
            XMLOutputter outputter = new XMLOutputter();
            outputter.setFormat(Format.getPrettyFormat());
            outputter.output(document, writer);
            outputter.output(document, System.out);
            
        }catch (IOException e) {
            e.printStackTrace();
        }
    }
    
    protected Document document;
    
}
